package cn.ecut;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;


public class jdbc3 {
    public static void main(String[] args) throws Exception{
        // 加载驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
        // 获取连接
        String url = "jdbc:mysql://localhost:3306/onetest?serverTimezone=Asia/Shanghai" ;
        String username = "root" ;
        String password = "" ;
        Connection connection = DriverManager.getConnection(url , username , password ) ;
        Statement statement = connection.createStatement() ;
        String SQL = "select id  , address from one where id > 3" ;
        ResultSet resultSet = statement.executeQuery(SQL);
        System.out.println( resultSet );
        while( resultSet.next() ){
            int id = resultSet.getInt("id");
            String countrycode = resultSet.getString("address") ;
            String object = resultSet.getObject("address", String.class);
            System.out.println(id + " " + object +" a"+countrycode );
        }
        resultSet.close();
        statement.close();
        connection.close();
    }
}
